package com.system.data.controller;


import com.system.data.model.*;
import com.system.data.service.*;
import org.ansj.domain.Result;
import org.ansj.splitWord.analysis.ToAnalysis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin(origins = "*", maxAge=3600)
@RestController
public class DataServiceController {
    @Autowired
    YmtService ymtService;

    @Autowired
    NonewService nonewService;

    @Autowired
    NjwService njwService;

    @Autowired
    AgriNyywService agriNyywService;

    @Autowired
    ChnAgriService chnAgriService;

    @Autowired
    ZcfgService zcfgService;

    @Autowired
    JingdongAttributeAervice jingdongAttributeAervice;

    @Autowired
    JingdongCommentService jingdongCommentService;

    @Autowired
    JingdongFrequencyService jingdongFrequencyService;

    @Autowired
    NywService nywService;

    @Autowired
    CommentSentimentService commentSentimentService;

    @GetMapping("/getYmtProdInfo")
    public List<YmtProductsInfo> findAllYmtProductsInfo(){
        return ymtService.findAllYmtProductsInfo();
    }

    @GetMapping("/getYmtProdVarInfo")
    public List<YmtProductsVarietiesInfo> findAllYmtProductsVarietiesInfo(){
        return ymtService.findAllYmtProductsVarietiesInfo();
    }

    @GetMapping("/getYmtProdOriInfo")
    public List<YmtProductsOriginInfo> findAllYmtProductsOriginInfo(){
        return ymtService.findAllYmtProductsOriginInfo();
    }

    @GetMapping("/getByDateCate")
    @ResponseBody
    public List<YmtProductsInfo> findByDateCate(@RequestParam String date, @RequestParam String cate){
        return ymtService.findByDateCate(date,cate);
    }

    @GetMapping("/getByStartEnd")
    @ResponseBody
    public List<YmtProductsInfo> findByStartEnd(@RequestParam String start, @RequestParam String end, @RequestParam String cateName){
        return ymtService.findByStartEnd(start,end,cateName);
    }

    @GetMapping("/getOriginByStartEnd")
    @ResponseBody
    public List<YmtProductsOriginInfo> getOriginByStartEnd(@RequestParam String start, @RequestParam String end, @RequestParam String cateName,@RequestParam String origin){
        return ymtService.findOriginByStartEnd(start,end,cateName,origin);
    }

    @GetMapping("/getAllOrigin")
    @ResponseBody
    public List<YmtProductsOriginInfo> findByAllOrigin(@RequestParam String marketDate, @RequestParam String cateName){
        return ymtService.findAllOrigin(marketDate, cateName);
    }

    @GetMapping("/getSiChuanJiangXi")
    @ResponseBody
    public List<YmtProductsSichuanJiangxiInfo> findSiChuanJiangXi(@RequestParam String marketDate, @RequestParam String cateName, @RequestParam String province){
        return ymtService.findSiChuanJiangXi(marketDate, cateName, province);
    }

    @GetMapping("/getBySpecies")
    @ResponseBody
    public List<YmtProductsInfo> findBySpecies(@RequestParam String marketDate, @RequestParam String species){
        return ymtService.findBySpecies(marketDate, species);
    }

    @GetMapping("/getHotByBuyer")
    @ResponseBody
    public List<YmtProductsHot> findHotByBuyer(@RequestParam String marketDate){
        return ymtService.findHotByBuyer(marketDate);
    }

    @GetMapping("/getHotBySeller")
    @ResponseBody
    public List<YmtProductsHot> findHotBySeller(@RequestParam String marketDate){
        return ymtService.findHotBySeller(marketDate);
    }

    @GetMapping("/getNonewInfo")
    @ResponseBody
    public List<NonewProductsInfo> getNonewInfo(){
        return nonewService.findAllNonewProductsInfo();
    }

    @GetMapping("/getNjwInfo")
    @ResponseBody
    public List<NjwProductsInfo> getNjwInfo(){
        return njwService.findAllNjwProductsInfo();
    }

    @GetMapping("/getAgriNyywInfo")
    @ResponseBody
    public List<AgriNyyw_info> getAgriNyywInfo(){
        return agriNyywService.findAllAgriNyywInfo();
    }

    @GetMapping("/getAgriNyywArtical")
    @ResponseBody
    public List<AgriNyywArtical> getAgriNyywArtical(@RequestParam String title){
        return agriNyywService.findArticalBytitle(title);
    }

    @GetMapping("/getByDateOriginSpecies")
    @ResponseBody
    public List<YmtProductsOriginInfo> getByDateOriginSpecies(@RequestParam String marketDate,@RequestParam String origin,@RequestParam String species){
        return ymtService.findByDateOriginSpecies(marketDate,origin,species);
    }

    @GetMapping("/getByDateOriginCate")
    @ResponseBody
    public List<YmtProductsOriginInfo> getByDateOriginCate(@RequestParam String marketDate,@RequestParam String origin,@RequestParam String cate){
        return ymtService.findByDateOriginCate(marketDate,origin,cate);
    }

    @GetMapping("/getAgriNyywInfoByProvince")
    @ResponseBody
    public List<AgriNyyw_info> getAgriNyywInfoByProvince(@RequestParam String province){
        return agriNyywService.findAgriNyywInfoByProvince(province);
    }

    @GetMapping("/getChnAgriNews")
    @ResponseBody
    public List<ChnAgri_info> getChnAgriNews(@RequestParam String today){
        return chnAgriService.getChnAgriNews(today);
    }

    @GetMapping("/getChnAgriArticle")
    @ResponseBody
    public List<ChnAgriArticle> getChnAgriArticle(@RequestParam String title){
        return chnAgriService.getChnAgriArticle(title);
    }

    @GetMapping("/getZcfgInfo")
    @ResponseBody
    public List<Zcfg_info> getZcfgInfo(){
        return zcfgService.findZcfgInfo();
    }

    @GetMapping("/getZcfgArticle")
    @ResponseBody
    public List<ZcfgArticle> getZcfgArticle(@RequestParam String title){
        return zcfgService.findZcfgArticle(title);
    }

    @GetMapping("/getJingDongProducts")
    @ResponseBody
    public List<JingdongAttribute830> getJingDongProducts(){
        return jingdongAttributeAervice.findJingDongProducts();
    }

    @GetMapping("/getJingDongOrderChoose")
    @ResponseBody
    public List<String> getJingDongOrderChoose(){
        return jingdongCommentService.findJingDongOrderChoose();
    }

    @GetMapping("/getJingDongComment")
    @ResponseBody
    public List<JingdongComment830> getJingDongComment(@RequestParam String orderChoose){
        return jingdongCommentService.findJingDongComment(orderChoose);
    }

    @GetMapping("/getJingDongFrequency")
    @ResponseBody
    public List<JingdongFrequency830> getJingDongFrequency(@RequestParam String variety){
        return jingdongFrequencyService.findJingDongFrequency(variety);
    }

    @GetMapping("/getOrderByMarketDate")
    @ResponseBody
    public List<YmtProductsOriginInfo> getOrderByMarketDate(){
        return ymtService.findOrderByMarketDate();
    }

    @GetMapping("/getMaxPriceOrigin")
    @ResponseBody
    public List<YmtProductsOriginInfo> getMaxPriceOrigin(@RequestParam String marketDate,@RequestParam String cate){
        return ymtService.findMaxPriceOrigin(marketDate,cate);
    }

    @GetMapping("/getMinPriceOrigin")
    @ResponseBody
    public List<YmtProductsOriginInfo> getMinPriceOrigin(@RequestParam String marketDate,@RequestParam String cate){
        return ymtService.findMinPriceOrigin(marketDate,cate);
    }

    @GetMapping("/getNywProductsInfoByCateDate")
    @ResponseBody
    public List<NywProductsInfo> getNywProductsInfoByCateDate(@RequestParam String cate,@RequestParam String date){
        return nywService.findNywProductsInfoByCateDate(cate,date);
    }

    @GetMapping("/getCommentSentimentByText")
    @ResponseBody
    public List<CommentSentiment> getCommentSentimentByText(@RequestParam String text){
        return commentSentimentService.findCommentSentimentByText(text);
    }

    @GetMapping("/parseText")
    @ResponseBody
    public Result parseText(@RequestParam String text){
        Result t = ToAnalysis.parse(text);
        return t;
    }

}
